{% extends "base.html" %}

{% block title %}Context Processors - Flask Templates Demo{% endblock %}

{% block content %}
<h2>Context Processors</h2>

<div class="row">
    <div class="col-md-6">
        <h3>Global Variables from Context Processors</h3>
        <table class="table">
            <thead>
                <tr>
                    <th>Variable</th>
                    <th>Value</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><code>site_name</code></td>
                    <td>{{ site_name }}</td>
                </tr>
                <tr>
                    <td><code>current_year</code></td>
                    <td>{{ current_year }}</td>
                </tr>
                <tr>
                    <td><code>navigation</code> items</td>
                    <td>{{ navigation|length }}</td>
                </tr>
            </tbody>
        </table>
        
        <h3>Navigation Menu (from context processor)</h3>
        <ul>
        {% for item in navigation %}
            <li><a href="{{ item.url }}">{{ item.name }}</a></li>
        {% endfor %}
        </ul>
    </div>
    
    <div class="col-md-6">
        <h3>Global Functions</h3>
        <p>Current timestamp from global function: {{ get_current_time() }}</p>
        
        <h3>Template Global Functions</h3>
        <p>Random number: {{ get_random_number() }}</p>
        <p>Formatted price: {{ format_price(123.45) }}</p>
    </div>
</div>

<div class="mt-4">
    <h3>Debug Information</h3>
    <div class="debug-info">
        <h4>All available template context variables:</h4>
        <pre>{{ pprint(dict(
            site_name=site_name,
            current_year=current_year,
            navigation=navigation|list,
            user=user,
            movies=movies|list
        )) }}</pre>
    </div>
</div>
{% endblock %}